package jzqb.dao.impl;

import cnki.tpi.kbatis.sqlsession.SqlSession;
import cnki.tpi.kbatis.utils.DataSourceUtil;
import jzqb.bo.MessageBo;
import jzqb.dao.MessageDao;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 自用库数据层实现类
 */
@Repository
public class MessageDaoImpl implements MessageDao {

    @Override
    public Boolean insertMessage(MessageBo messageBo) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "jzqb.dao.MessageDao.insertMessage";
        return sqlSession.executeInsert(statementId, messageBo);
    }

    @Override
    public List<MessageBo> getMessageList(MessageBo messageBo) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "jzqb.dao.MessageDao.getMessageList";
        return sqlSession.selectList(statementId, messageBo, false);
    }

    @Override
    public Long getMessageListCount(MessageBo messageBo) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "jzqb.dao.MessageDao.getMessageListCount";
        return sqlSession.getCount(statementId, messageBo);
    }

    @Override
    public Boolean deleteMessage(MessageBo messageBo) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "jzqb.dao.MessageDao.deleteMessage";
        return sqlSession.executeDelete(statementId, messageBo);
    }
}
